﻿<mpc:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:mpc="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:NYTimes="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit" 
    xmlns:NYTimes_ValueConverters="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    x:Class="NYTMovieReviews.DetailsPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
    d:DataContext="{d:DesignInstance NYTimes:MovieReviewsByKeyword, IsDesignTimeCreatable=True}" Orientation="Portrait" SupportedOrientations="PortraitOrLandscape"
    >
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
    <!--Page transition animation-->
    <mpc:PhoneApplicationPage.Resources>
    	<NYTimes_ValueConverters:VisibleIfTrueConverter x:Key="VisibleIfTrueConverter"/>
    	<NYTimes_ValueConverters:DateTimeConverter x:Key="DateTimeConverter"/>
    	<DataTemplate x:Key="LinkTemplate">
    		<Grid d:DesignWidth="224" d:DesignHeight="59">
    			<Button HorizontalAlignment="Left" d:LayoutOverrides="Height" Tag="{Binding Url}" Click="Button_Click" Width="240">
    				<TextBlock TextWrapping="Wrap" Text="{Binding SuggestedLinkText}" Style="{StaticResource PhoneTextSmallStyle}" TextAlignment="Center"/>
    			</Button>
    		</Grid>
    	</DataTemplate>
    	<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
    		<toolkit:WrapPanel>
    		</toolkit:WrapPanel>
    	</ItemsPanelTemplate>
    </mpc:PhoneApplicationPage.Resources>

    <mpc:PhoneApplicationPage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
    </mpc:PhoneApplicationPage.FontFamily>
    <mpc:PhoneApplicationPage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
    </mpc:PhoneApplicationPage.FontSize>
    <mpc:PhoneApplicationPage.Foreground>
		<StaticResource ResourceKey="PhoneForegroundBrush"/>
    </mpc:PhoneApplicationPage.Foreground>

    <!--Data context is set to sample data above and first item in sample data collection below-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}" d:DataContext="{Binding Results[0]}">
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="VisualStateGroup">
    			<VisualStateGroup.Transitions>
    				<VisualTransition GeneratedDuration="0:0:0.5">
    					<VisualTransition.GeneratedEasingFunction>
    						<CubicEase EasingMode="EaseOut"/>
    					</VisualTransition.GeneratedEasingFunction>
    				</VisualTransition>
    			</VisualStateGroup.Transitions>
    			<VisualState x:Name="Details"/>
    			<VisualState x:Name="Browser"/>
    		</VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>
        <Grid.RowDefinitions>
        	<RowDefinition Height="Auto"/>
        	<RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitleGrid is the name of the application and page title-->

    	<StackPanel x:Name="TitleGrid" Grid.Row="0">
    		<StackPanel.Projection>
    			<PlaneProjection/>
    		</StackPanel.Projection>
            
    		<TextBlock Text="New York Times Movie Reviews" Style="{StaticResource PhoneTextTitle3Style}"/>
    		<TextBlock Text="{Binding DisplayTitle}" Style="{StaticResource PhoneTextTitle1Style}" TextWrapping="Wrap"/>
    	</StackPanel>

    	<Grid x:Name="ContentGrid" Grid.Row="1">
    		<Grid.Projection>
    			<PlaneProjection/>
    		</Grid.Projection>
    		<ScrollViewer>
    			<StackPanel Orientation="Vertical">
            
    				<TextBlock Text="{Binding Headline}" Style="{StaticResource PhoneTextNormalStyle}"/>
    				<Grid Margin="20,5">
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition Width="Auto"/>
    						<ColumnDefinition/>
    						<ColumnDefinition Width="Auto"/>
    					</Grid.ColumnDefinitions>
    					<Image Source="{Binding Thumbnail}" VerticalAlignment="Top"/>
    					<StackPanel Orientation="Vertical" Margin="20,0" Grid.Column="1" VerticalAlignment="Top">
    						<StackPanel Orientation="Horizontal">
    							<TextBlock TextWrapping="Wrap" Text="by " Style="{StaticResource PhoneTextSmallStyle}" Margin="0"/>
    							<TextBlock TextWrapping="Wrap" Text="{Binding Byline}" Style="{StaticResource PhoneTextSmallStyle}" Margin="0"/>
    						</StackPanel>
    						<TextBlock TextWrapping="Wrap" Text="Critics' Pick" HorizontalAlignment="Left" Visibility="{Binding CriticsPick, Converter={StaticResource VisibleIfTrueConverter}}">
    							<TextBlock.Foreground>
    								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
    							</TextBlock.Foreground>
    						</TextBlock>
    					</StackPanel>
    					<StackPanel Grid.Column="2" HorizontalAlignment="Right" Orientation="Vertical" d:LayoutOverrides="Height">
    						<StackPanel Orientation="Horizontal">
    							<TextBlock TextWrapping="Wrap" Text="{Binding PublicationDate, ConverterParameter=d, Converter={StaticResource DateTimeConverter}}" Style="{StaticResource PhoneTextSmallStyle}" Margin="0,0,9,0"/>
    							<Border BorderBrush="White" BorderThickness="2" VerticalAlignment="Top" Padding="2,0" HorizontalAlignment="Right">
    								<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding MPAARating}" VerticalAlignment="Center" Style="{StaticResource PhoneTextSmallStyle}" FontWeight="Bold"/>
    							</Border>
    						</StackPanel>
    						<TextBlock HorizontalAlignment="Right" Text="1,000 Best" Visibility="{Binding ThousandBest, Converter={StaticResource VisibleIfTrueConverter}}">
    							<TextBlock.Foreground>
    								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
    							</TextBlock.Foreground>
    						</TextBlock>
    					</StackPanel>
    				</Grid>
    				<TextBlock TextWrapping="Wrap" Text="{Binding CapsuleReview}" Style="{StaticResource PhoneTextNormalStyle}" Margin="20,0"/>
    				<TextBlock
    					TextWrapping="Wrap" Text="{Binding SummaryShort}" Style="{StaticResource PhoneTextNormalStyle}" Margin="20,0"/>
    				<Button Content="{Binding Link.SuggestedLinkText}" HorizontalAlignment="Left" Tag="{Binding Link.Url}" Click="Button_Click"/>
    				<ItemsControl ItemsSource="{Binding RelatedUrls}" ItemTemplate="{StaticResource LinkTemplate}" ItemsPanel="{StaticResource ItemsPanelTemplate1}"/>
                   
                </StackPanel>
    		</ScrollViewer>
        </Grid>
    </Grid>
    
</mpc:PhoneApplicationPage>